package com.one.group.admin.listener;

import com.one.group.admin.dao.impl.ChargeInfoDaoImpl;
import com.one.group.model.entity.ChargeInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class chargeInfoListener {
    @Autowired
    private ChargeInfoDaoImpl chargeInfoDao;
    /**
     * 监听新增收费信息
     * @param chargeInfo 收费信息
     */
    @RabbitListener(bindings = @QueueBinding(value = @Queue(name = "direct.queue3"),
            exchange = @Exchange(name = "gxa.direct"), key = {"recordChargeInfoDto"}))
    public void listenerDirectQueue1Message(ChargeInfo chargeInfo) {
        log.info("监听到消息：{}", chargeInfo);
        chargeInfoDao.insertChargeInfo(chargeInfo);
    }
}
